﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Vds2465Telegrams;

namespace Vds2465Parser
{
	[TestClass]
	public class GenParse_UserData_30_RepType01Numbers_Test
	{
		#region positive "small" integral values

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test01_20_0()
		{
			const double measurementValue = 20.0;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);	
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test02_511_0()
		{
			const double measurementValue = 511;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test03_1_0()
		{
			const double measurementValue = 1.0;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test04_0_0()
		{
			const double measurementValue = 0.0;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		#endregion positive "small" integral values

		#region negative "small" integral values

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test10__1_0()
		{
			const double measurementValue = -1.0;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test11__512_0()
		{
			const double measurementValue = -512.0;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		#endregion negative "small" integral values

		#region positive "big" integral values

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test20_512_0()
		{
			const double measurementValue = 512.0;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test21_1024_0()
		{
			const double measurementValue = 1024.0;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test22_2048_0()
		{
			const double measurementValue = 2048.0;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test23_4096_0()
		{
			const double measurementValue = 4096.0;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		#endregion positive "big" integral values

		#region negative "big" integral values

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test30__512_0()
		{
			const double measurementValue = -512.0;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test31__1024_0()
		{
			const double measurementValue = -1024.0;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test32__2048_0()
		{
			const double measurementValue = -2048.0;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test33__4096_0()
		{
			const double measurementValue = -4096.0;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		#endregion negative "big" integral values

		#region positive "small" double values

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test40_1_25()
		{
			const double measurementValue = 1.25;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test41_100_50()
		{
			const double measurementValue = 100.50;
			byte lowByte;
			byte highByte;
			GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

			double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
			Assert.AreEqual(measurementValue, measurementValue2Compare);
		}

		#endregion positive "small" double values


		// TODO the following out-commented unit tests fail ...

		//#region positive "big" double values

		//[TestMethod]
		//[Owner("Frank Eppink")]
		//public void Test40_1024_25()
		//{
		//    const double measurementValue = 1024.25;
		//    byte lowByte;
		//    byte highByte;
		//    GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

		//    double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
		//    Assert.AreEqual(measurementValue, measurementValue2Compare);
		//}

		//[TestMethod]
		//[Owner("Frank Eppink")]
		//public void Test41_50000_75()
		//{
		//    const double measurementValue = 50000.75;
		//    byte lowByte;
		//    byte highByte;
		//    GenParse_UserData_30_RepType01Numbers.Generate_RepType01_Bytes(measurementValue, out lowByte, out highByte);

		//    double measurementValue2Compare = GenParse_UserData_30_RepType01Numbers.Parse_RepType01_Bytes(lowByte, highByte);
		//    Assert.AreEqual(measurementValue, measurementValue2Compare);
		//}

		//#endregion positive "small" double values
	}
}
